<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 递归：阶乘 5
    // 计算n的阶乘
    function fn(n) {
      if (n === 1) {
        console.log('递归结束' + n)
        return 1
      } else {
        // n > 1
        console.log('递归前' + n)
        const ret = n * fn(n - 1)
        console.log('递归后' + n)
        return ret
      }
    }
    const ret = fn(5)
    console.log(ret)

  </script>
</body>
</html>
